package cn.zcf.pet.service.impl;

import cn.zcf.basic.service.impl.BaseServiceImpl;
import cn.zcf.pet.domain.Pet;
import cn.zcf.pet.domain.PetDetail;
import cn.zcf.pet.mapper.PetDetailMapper;
import cn.zcf.pet.mapper.PetMapper;
import cn.zcf.pet.service.IPetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;

@Service
public class PetServiceImpl extends BaseServiceImpl<Pet> implements IPetService {
    @Autowired
    private PetMapper petMapper;
    @Autowired
    private PetDetailMapper petDetailMapper;
    @Override
    public void add(Pet pet) {
        petMapper.add(pet);
        PetDetail detail = pet.getPetDetail();
        detail.setPet_id(pet.getId());
        petDetailMapper.add(detail);
    }

    @Override
    public void update(Pet pet) {
        petMapper.update(pet);
        petDetailMapper.update(pet.getPetDetail());
    }

    @Override
    public void onSale(List<Long> ids) {

        petMapper.onSale(ids,new Date());
    }

    @Override
    public void offSale(List<Long> ids) {
        petMapper.offSale(ids,new Date());
    }
}
/*
    //2.智能审核
    Boolean textBoo = baiduAiAuditService.textAudit(s.getTitle() + s.getName() + s.getAddress());
    Boolean imageBoo = true*/
/*baiduAiAuditService.imageAudit(s.getResources())*//*
;
        if(textBoo && imageBoo){
                s.setState(1);
                s.setNote("审核成功");
                searchMessageMapper.update(s);
                SearchMessageLog log = new SearchMessageLog();
                log.setState(1);
                log.setNote("审核成功");
                log.setMsg_id(s.getId());
                searchMessageLogMapper.add(log);
                }else{
                s.setState(0);
                s.setNote("信息异常审核失败");
                searchMessageMapper.update(s);
                SearchMessageLog log = new SearchMessageLog();
                log.setState(0);
                log.setNote("审核失败");
                log.setMsg_id(s.getId());
                searchMessageLogMapper.add(log);
                }*/
